<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>注册</title>
		<link rel="stylesheet" type="text/css" href="css/site.css" />
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">
		<!-- 引入组件 -->
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vant@1.6/lib/vant.min.js"></script>
	</head>
	<body>
		<div id="app">
			<!-- 头部 -->
			<van-nav-bar id="S_bar" fixed=true style="background-color: #F40;" title="注册用户" left-arrow @click-left="onClickLeft"></van-nav-bar>
			<!-- 内容 -->
			<!-- <div style="height: 20px;background-color: gainsboro;"></div> -->
			<van-cell-group>
				<van-field v-model="phone" placeholder="手机号码"></van-field>
				<van-cell-group>
					<van-field v-model="Code" center clearable placeholder="验证码(6位数字短信验证码)">
						<van-button slot="button" size="normal" type="danger" @click="yz">发送验证码</van-button>
					</van-field>
				</van-cell-group>
				<van-field v-model="pwd" type="password" placeholder="登录密码(最少六位)"></van-field>
				<van-field v-model="AffirmPwd" type="password" placeholder="确认密码(再次输入登录密码)"></van-field>
				<van-field v-model="nickName" placeholder="昵称(最多20字)"></van-field>
				<van-field v-model="districtCode" placeholder="县/区Code"></van-field>
				<van-row>
					<van-col span="24" align="center" style="font-size: 14px;margin: 20px 0;">注册会员即表示同意<a href="#">《万众雅讯用户注册协议》</a></van-col>
					<van-col span="20" offset="2" align="center">
						<van-button size="large" type="danger" @click="zc">立即注册</van-button>
					</van-col>
				</van-row>
			</van-cell-group>
		</div>
		<script src="js/ajax.js"></script>
		<script>
			var app = new Vue({
				el: "#app",
				data: {
					Code:"",
					phone:"",
					pwd:"",
					AffirmPwd:"",
					nickName:"",
					districtCode:""
				},
				methods: {
					onClickLeft() {
						window.location.href = "login.html";
					},
					yz(){
						_this = this;
						ajax({
							url: "http://dsapi.ysd3g.com/API/SendRegisterPhoneCode",
							data:{phone: _this.phone},
							dataType: "jsonp",
							success: function(res) {
								console.log(res)
								if(!res.Error){
									_this.Code = res.Code
									alert(res.Code)
								}else{
									alert("获取失败");
								}
							}
						})
					},
					zc(){
						_this = this;
						ajax({
							url: "http://dsapi.ysd3g.com/API/UserRegister",
							data:{phone: _this.phone,code: _this.Code, password: _this.pwd,districtCode: _this.districtCode,nickName: _this.nickName},
							dataType: "jsonp",
							success: function(res) {
								console.log(res)
								if(!res.Error){
									alert("注册成功！")
									plus.webview.create("login.html","login").show();
								}else{
									alert(res.Msg)
								}
							}
						})
					}
				}
			})
		</script>
	</body>
</html>
